package calao;

import static calao.util.Logger.*; 
import org.mortbay.log.Logger;

import calao.util.LogLevel;

public class JettyLogger
implements Logger
{

	public void debug(String msg, Throwable th) { }

	public void debug(String msg, Object arg1, Object arg2) { }

	public Logger getLogger(String name) 
	{
		return this;
	}

	public void info(String msg, Object arg1, Object arg2) 
	{
		logJettyMsg(INFO, msg, arg1, arg2);
	}

	public boolean isDebugEnabled() 
	{
		return false;
	}

	public void setDebugEnabled(boolean enabled) { }

	public void warn(String msg, Throwable th) 
	{ 
		log(th);
		logJettyMsg(ERROR, msg, null, null);
	}

	public void warn(String msg, Object arg1, Object arg2) 
	{
		logJettyMsg(ERROR, msg, arg1, arg2);
	}
	
	void logJettyMsg(LogLevel level, String msg, Object arg1, Object arg2)
	{
		if (arg2!=null) log(level, "Jetty: %s %s %s", msg, arg1, arg2);
		else if (arg1!=null) log(level, "Jetty: %s %s", msg, arg1);
		else if (msg!=null) log(level, "Jetty: %s", msg);		
	}

}
